﻿using DFGK.WMS.Common.Result;
using DFGK_WMS.IRepository;
using DFGK_WMS.Repository;
using DFGK_WMS.WebAPI.Controllers.Result;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System.Net.Http;

namespace DFGK_WMS.WebAPI.Controllers.盘点管理
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class TStocktakeResultRecordController : ControllerBase
    {
        public TStocktakeResultRecordController(ITStocktakeResultRecordRepository tStocktakeResultRecordRepository)
        {
            TStocktakeResultRecordRepository = tStocktakeResultRecordRepository;
        }

        public ITStocktakeResultRecordRepository TStocktakeResultRecordRepository { get; }

        /// <summary>
        /// 盘点库显示
        /// </summary>
        /// <param name="wid"></param>
        /// <param name="aid"></param>
        /// <param name="status"></param>
        /// <param name="isHandle"></param>
        /// <param name="orderSN"></param>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        [HttpGet]
        public IActionResult GetTStocktakeResultRecordList(int wid=0, int aid=0, int status=0, int isHandle=2, string? orderSN="", int pageIndex=1, int pageSize=10)
        {
            if (pageIndex <= 0 || pageSize <= 0)
            {
                return Ok(BaseResult.Result("400", "分页条件有误！"));
            }
            int totalCount;

            var list = TStocktakeResultRecordRepository.GetTStocktakeResultRecordList(wid, aid,status,isHandle,orderSN, pageIndex, pageSize, out totalCount);

            if (list != null)
            {
                return Ok(BaseResult.Result(list, "查询成功！", "200", totalCount));
            }
            return Ok(BaseResult.Result(null, "查询失败！", "500", 0));
        }
    }
}
